/*
 * cantest.h
 *
 *  Created on: 2016年7月18日
 *      Author: root
 */

#ifndef DMATEST_H_
#define DMATEST_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <linux/ioctl.h>

#define   tlp_size  512*1024
#define   buf_size  tlp_size*4


//CAN帧结构定义
typedef struct
{
	unsigned char  id;    //消息ID
	unsigned char data[buf_size]; //消息数据
}xbmd_frame, *pxbmd_frame;



//IOCTL 控制字
#define XBMD_CTL_TYPE 	'O'

#define INITCARD              _IOW(XBMD_CTL_TYPE,0x10, unsigned int)  // Initailizes XBMD board
#define INITRST               _IOW(XBMD_CTL_TYPE,0x11, unsigned int)  //  Resets XBMD board
#define WRDDMACR              _IOW(XBMD_CTL_TYPE,0x12, unsigned int)  // Write: DMA Control Status Register， bit0=1 时表示板卡DMA写操作，bit0=0 时表示板卡DMA读操作
#define WRDDMAST              _IOW(XBMD_CTL_TYPE,0x13, unsigned int)  // Write: DMA Control Enable Register， bit0=1 时命令锁存
#define WRWDMATLPS            _IOW(XBMD_CTL_TYPE,0x14, unsigned int)  // Write: Write DMA TLP Size Register, 单位DW
#define USR_DMA_END           _IOW(XBMD_CTL_TYPE,0x15, unsigned int)  // Write: USER DMA END
#define USR_ID_UP             _IOW(XBMD_CTL_TYPE,0x16, unsigned int)  // Write: USER ID UPDATA
#define DMASTATUS             _IOR(XBMD_CTL_TYPE,0x17, unsigned int)  // READ:  DMA STATUS 


#define RDDMAWRTLPCLKN        _IOR(XBMD_CTL_TYPE,0x18, unsigned int)  // READ: DMA WRITE TLP CLK NUMBER
#define RDDMARDTLPCLKN        _IOR(XBMD_CTL_TYPE,0x19, unsigned int)  // READ: DMA READ TLP CLK NUMBER
#define FPGAVERSION           _IOR(XBMD_CTL_TYPE,0x1a, unsigned int)  // READ: FPGA VERSION


#define ID_NUM               _IOR(XBMD_CTL_TYPE,0x1b, unsigned int)  // READ: chan ID

#define FPGA_VER_RDREG      0
#define DMAWR_CLKNUM_RDREG  1
#define DMARD_CLKNUM_RDREG  2
#define USR_DMAEND_RDREG    3

//#define DIS_DMA_TRANS    0x2
#define DIS_DMA_TRANS    0x4


static int g_fd;


#endif /* DMATEST_H_ */
